﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLNhaThuoc.DAL;

namespace QLNhaThuoc.DTO
{
    class ThuocNormalStockState:ThuocState
    {
        public ThuocNormalStockState(Thuoc thuoc)
        {
            _thuoc = thuoc;
            //_soLuong = soLuong;
        }

        public ThuocNormalStockState(ThuocState state)
        {
            _thuoc = state.Thuoc;
            _soLuong = state.SoLuong;
        }

        public override int Sell(int sellQuantity)
        {
            if (sellQuantity >= SoLuong)
            {
                _thuoc.State = new ThuocLowStockState(this);
                sellQuantity = _thuoc.Sell(sellQuantity);
            }
            else
            {
                _soLuong -= sellQuantity;
            }

            return sellQuantity;
        }

        public override void Restock(int restockQuantity)
        {
            _soLuong += restockQuantity;
        }
    }
}
